package com.ecfront.util.email;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ResourceBundle;

/**
 * Email辅助类
 * @author www.ecfront.com
 */
public class MailUtil {
	private static String systemPath;
	public static String getSystemPath() {
		return systemPath;
	}
	public static void setSystemPath(String systemPath) {
		MailUtil.systemPath = systemPath;
	}
	/**
	 * 根据文件路径，返回该文件包含的内容
	 * @param filePath
	 * @return
	 */
	public static String getFileContextByPath(String filePath){
		FileInputStream fileInput = null;
		StringBuilder str = new StringBuilder();
		try {
			fileInput = new FileInputStream(filePath);
			byte[] bytes = new byte[1024];
			while(fileInput.read(bytes)!=-1){
				str.append(new String(bytes));
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally{
			try {
				fileInput.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return str.toString();
	}	
}
